import { request } from '../../utils/request.js'
import { useAuthStore } from "../../store/authStore.js"


const auth = useAuthStore()

const getAuthInfo = () => {
    return refreshAuth() // 懒得改代码了，就这样吧，虽然函数直接调函数没啥用
}


// 内部方法，调用接口刷新authStore的内容
async function refreshAuth() {
    const res = await request({
        url: '/user/info'
    })

    if (res.code == 200) {
        auth.updateInfo(res.data)
    }
    
    return res
}

export {
    getAuthInfo
}